﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Skyhook.Core;

namespace Skyhook.Isometry
{
    internal class WorldScreenPosition : IScreenPosition, IPositionListener
    {
        WorldPosition pPosition = null;
        Vector2 pShift;

        public WorldScreenPosition(WorldPosition position)
        {
            if( position == null )
            {
                throw new Exception("Position is null.");
            }
            pPosition = position;
        }

        public virtual float X
        {
            get
            {
                return pPosition.X;
            }
        }

        public virtual float Y
        {
            get
            {
                return pPosition.Y;
            }
        }

        public virtual Vector2 Position
        {
            get
            {
                return pPosition.Position;
            }
        }

        public virtual Point ScreenPosition
        {
            get
            {
                return CoordinatesConverter.ConvertWorldToScreen(pPosition.X + pShift.X, pPosition.Y + pShift.Y);
            }
        }

        public virtual Vector2 Shift
        {
            set
            {
                pShift = value;
            }
        }

        public float Depth
        {
            get
            {
                return (float)((int)pPosition.X + (int)pPosition.Y) / 128.0f;
            }
        }
    }
}
